<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>监理服务系统</title>
    <!--公用样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/comment.css"/>
    <!--页面样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/style.css"/>
    <!--Layui-->
    <link rel="stylesheet" href="${re.contextPath}/plugin/layui/css/layui.css" media="all"/>
    <!--页面样式-->
    <link rel="stylesheet" type="text/css" href="${re.contextPath}/plugin/common/css/extended.css"/>
    <!--JQ-->
    <script type="text/javascript" charset="utf-8"
            src="${re.contextPath}/plugin/common/js/jquery-1.8.3.min.js"></script>
    <!--Layui-->
    <script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.js" charset="utf-8"></script>
    <!--公用样式JS-->
    <script type="text/javascript" charset="utf-8" src="${re.contextPath}/plugin/common/js/comment.js"></script>
    <!--进度条-->
</head>


<body>
<!--容器-->

<div class="container clearfix">
    <div class="downModule whitebg" style="height: 100%;">
        <div id="jfsqts">
            <input type="hidden" name="type" id="type" value="${type}">
            <input type="hidden" name="projectId" id="projectId" value="${projectId}">
            <input type="hidden" name="fileName" id="fileName" value="${fileName}">
            <input type="hidden" name="fileId" id="fileId" value="${fileId}">
            <div style="align-content: center;padding: 20px;">
                <h3 align="center">选择接收人</h3>
                <h4 align="left">业主单位：${pdto.owerCompany}</h4>
                <div id="jfsqyz_lxbox">
                    <#list listleader as vo>
                        <span> <input type="checkbox" style="margin-right: 20px;margin-top: 0px;" name="name"
                                      id="${vo.projectLeader}"
                                      title="${vo.realName}"></span>
                        <span>${vo.realName}</span>
                    </#list>
                </div>
                <#if "${type}" =='004' >
                    <div id="jfsqcj_lxbox">
                        <h4 align="left">承建单位：</h4>
                        <#list listcj as vo>
                            <div>
                            <span><input type="checkbox" style="margin-right: 20px;margin-top: 0px" name="name"
                                         id="${vo.projectManager}" title="${vo.realName}">   </span>
                                <span>${vo.unitConstruction}</span>
                                <span>${vo.realName}</span>
                            </div>
                        </#list>
                    </div>
                </#if>
            </div>
        </div>
        <div class="popUpBtn center">
            <button type="button" class="blue bgnone close">关闭</button>
            <button type="button" class="bluebg white" id="commit" onclick="commitClick()">提交</button>
        </div>
    </div>
</div>
<!--公用样式JS-->
<script type="text/javascript" src="${re.contextPath}/plugin/tools/tool.js"></script>
<script type="text/javascript" src="${re.contextPath}/plugin/tools/cardUtils.js"></script>

<script type="text/html" id="toolBar">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看详情</a>
</script>

<script>
    var layer, form, laydate, upload, uploadListIns, element, tableIns, table;
    $(function () {
        layui.use(['form', 'layer', 'element'], function () {
            laydate = layui.laydate;
            form = layui.form;
            element = layui.element;
        });

    });

    function commitClick() {

        var type = '${type}';
        var projectId = '${projectId}';
        var fileName = '${fileName}';
        var fileId = '${fileId}';
        var selectCount = 0;
        var selectCountcj = 0;
        var yzUserId = "";
        var cjUserId = "";
        $("#jfsqyz_lxbox [type=checkbox]:checked").each(function (i, v) {
            var userId = $(v).attr("id");
            yzUserId = yzUserId + userId + ",";
            selectCount++;
        });
        if (type == '004') {
            // 监发三签
            $("#jfsqcj_lxbox [type=checkbox]:checked").each(function (i, v) {
                var userId = $(v).attr("id");
                cjUserId = cjUserId + userId + ",";
                selectCountcj++;
            });
        }
        if (selectCount == 0) {
            layer.msg("请选择业主单位", {icon: 2});
            return;
        }
        if (type == '004') {
            if (selectCountcj == 0) {
                layer.msg("请选择承建单位", {icon: 2});
                return;
            }
            cjUserId = cjUserId.substr(0, cjUserId.length - 1);
        }
        yzUserId = yzUserId.substr(0, yzUserId.length - 1);

        var jsonsp = {
            type: type,//监发三签
            projectId: projectId,
            fileId: fileId,
            fileName: fileName,
            yzUserId: yzUserId,
            cjUserId: cjUserId
        }
        $('#commit').addClass("layui-btn-disabled").attr("disabled", true);
        layerAjax('/supervisor/lcManager/updateStartLc', jsonsp, '', function (d) {
            if (d.flag == true) {
                layer.msg(d.msg);
                setTimeout(function () {
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.layer.close(index);
                }, 2000)
            } else {
                $('#commit').removeClass("layui-btn-disabled").attr("disabled", false);
                layer.msg(d.msg, {icon: 2});
            }
            console.log(d);
        });

    }

    $('.close').click(function () {
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
    });

    function checkClick(checkStatus) {
        //按钮不可用
        $('[type=button]').addClass("layui-btn-disabled").attr("disabled", true);
        var checkStatus = checkStatus;
        var type = "auto";
        if (checkStatus == "3") {
            //填写驳回原因
            layer.open({
                type: 1
                ,
                offset: type, //
                area: ['600px', '300px'],
                id: 'layerDemo' + type //防止重复弹出
                ,
                content: '<div style="align-content: center;"><div style="margin-top: 10px;margin-left: 60px;font-weight:bold;" class="b">驳回原因</div><textarea id="remark"  name="remark" style="width: 450px;height: 100px;margin-left: 60px;margin-bottom: 10px;" placeholder="请填写驳回原因"></textarea></div>'
                ,
                btn: '关闭全部'
                ,
                btnAlign: 'c' //按钮居中
                ,
                shade: 0 //不显示遮罩
                ,
                btn: ['确定', '关闭'] //只是为了演示
                ,
                yes: function () {
                    var remark = $("#remark").val();
                    if (!remark) {
                        layer.msg("请输入驳回原因", {icon: 2});
                        return
                    } else {
                        doCheck(checkStatus);
                    }

                }
                ,
                btn2: function () {
                    layer.closeAll();
                }
            });

        } else {
            doCheck(checkStatus);
        }
    }


</script>
</body>

</html>